if ( SERVER ) then

	AddCSLuaFile( "shared.lua" )
	
	SWEP.HoldType			= "shotgun"
	
end

if ( CLIENT ) then

        SWEP.Category 		= "HL2 Beta Sweps"
	SWEP.PrintName			= "Fire Extinguisher"			
	SWEP.Author				= "Valve"

	SWEP.ViewModelFOV		= 70
	SWEP.IconLetter			= "x"

end
-----------------------Main functions----------------------------
function SWEP:Reload()
end 
 
function SWEP:Think()

end

function SWEP:Initialize()
util.PrecacheSound("weapons/extinguisher/fire1.wav")
end
 
function SWEP:PrimaryAttack()
                     
local curtime = CurTime()

         self.Weapon:SendWeaponAnim("ACT_VM_PRIMARYATTACK")
		self.Weapon:EmitSound(weapons/extinguisher/fire1.wav)
	end
	
	local PlayerVel = self.Owner:GetVelocity()
	local PlayerPos = self.Owner:GetShootPos()
	local PlayerAng = self.Owner:GetAimVector()
	
	local trace = {}
	trace.start = PlayerPos
	trace.endpos = PlayerPos + (PlayerAng*4096)
	trace.filter = self.Owner
	
	local traceRes = util.TraceLine(trace)
	local hitpos = traceRes.HitPos
	
	local jetlength = (hitpos - PlayerPos):Length()
	
		if jetlength > 568 then 
		jetlength = 568
		elseif self.DoShoot then
	
		local normal = traceRes.HitNormal

			if traceRes.HitNonWorld then
				local hitent = traceRes.Entity
				local enttype = hitent:GetClass()
				if hitent:IsNPC() or hitent:IsPlayer() or enttype == "prop_physics" or enttype == "prop_vehicle" then
					local hitenttable = hitent:GetTable()
					hitenttable.FuelLevel = hitenttable.FuelLevel or 0
					hitenttable.FuelLevel = hitenttable.FuelLevel + 1
					util.Decal("extinguish2", hitpos + normal, hitpos - normal )
				end

                                        util.Decal("extinguish2", hitpos + normal, hitpos - normal )
                                      
                                	end
			
			if SERVER then
				for key,found in pairs(ents.FindInSphere(hitpos,32)) do
					local foundname = found:GetName()
					
					if found:GetClass() == "entityflame"
					or found:GetName() == "BurningFire"
					or found:GetName() == "flameparticle" then 

                                        ent_remove(ent_fire,hitpos)
                                 
                                    end

                         end

	              if jetlength < 6 then jetlength = 6 end

	              local effectdata = EffectData()
	              effectdata:SetEntity( self.Weapon )
	              effectdata:SetStart( PlayerPos )
	              effectdata:SetNormal( PlayerAng )
	              effectdata:SetScale( jetlength )
	              effectdata:SetAttachment( 1 )
	              util.Effect( "splash3", effectdata )
                   end	
 
          end 
       
function SWEP:SecondaryAttack()

end

function SWEP:Deploy()
	--self.Weapon:EmitSound(Sound("weapons/pistol_ready.wav"))
       self.Weapon:SendWeaponAnim("ACT_VM_DRAW")
end
-------------------------------------------------------------------

------------General Swep Info---------------
SWEP.Author   = "Valve"
SWEP.Contact        = "n/a"
SWEP.Purpose        = "Put Out Fires"
SWEP.Instructions   = "Primary= Shoot Fire Extinguisher"
SWEP.Spawnable      = true
SWEP.AdminSpawnable  = true
-----------------------------------------------

------------Models---------------------------
SWEP.ViewModel      = "models/weapons/v_fire_extinguisher.mdl"
SWEP.WorldModel   = "models/weapons/w_fire_extinguisher.mdl"
-----------------------------------------------

-------------Primary Fire Attributes----------------------------------------
SWEP.Primary.Delay			= 0.9 	--In seconds
SWEP.Primary.Recoil			= 0.1		--Gun Kick
SWEP.Primary.Damage			= 0	--Damage per Bullet
SWEP.Primary.NumShots		= 10		--Number of shots per one fire
SWEP.Primary.Cone			= 0.2 	--Bullet Spread
SWEP.Primary.ClipSize		= -1	--Use "-1 if there are no clips"
SWEP.Primary.DefaultClip	= -1	--Number of shots in next clip
SWEP.Primary.Automatic   	= true	--Pistol fire (false) or SMG fire (true)
SWEP.Primary.Ammo         	= "pistol"	--Ammo Type
-------------End Primary Fire Attributes------------------------------------
 